import http from '@src/util/http';

/**
 *
 * @description 获取组织架构 树级列表
 * @returns {*}
 */
export function getDepartmentTree (params) {
  return http.get('/security/department/tree', params)
}

/**
 * @description 获取组织架构部门下人员数量
 * @returns {*}
 */
export function getDepartmentUserCount (params) {
  return http.get('/security/department/depUserCount')
}

/**
 * @description 获取组织架构部门下 人员列表
 * @returns {*}
 */
export function getDepartmentUser (params) {
  return http.get('/security/department/user', params)
}

/**
 * @description 删除部门人员
 * @param {String} userIdList 用户id列表 ,分割
 * @param {String} departmentId 部门id
 * @returns {*}
 */
export function deleteBatchDepartmentUserByIdList (params) {
  return http.post('/security/department/deleteBatchDepartmentUserByIdList', params, false)
}

/**
 * @description 添加部门人员
 * @param {String} userIdList 用户id列表 ,分割
 * @param {String} departmentId 部门id
 * @returns {*}
 */
export function addDepartmentUser (params) {
  return http.post('/security/department/createAndAddDepartmentUser', params.loginUser)
}

/**
 * @description 添加部门
 * @param {String} name 部门名称
 * @param {String} parentId 上级部门id
 * @param {String} description 介绍
 * @param {String} type 类型
 * @returns {*}
 */
export function addDepartment (params) {
  return http.post('/security/department/update', params, false)
}

/**
 * @description 更新部门
 * @param {String} id 部门id
 * @param {String} name 部门名称
 * @param {String} parentId 上级部门id
 * @param {String} description 介绍
 * @param {String} type 类型
 * @returns {*}
 */
export function updateDepartment (params) {
  return http.post('/security/department/update', params, false)
}

/**
 * @description 删除部门
 * @param {String} departmentId 部门id
 * @returns {*}
 */
export function deleteDepartment (params) {
  return http.post(`/security/department/delete/${params.id}`)
}

/**
 * @description 调整部门
 * @param {String} userId 用户ID
 * @param {String} primaryDepartment 原部门
 * @param {String} freshDepartment  新部门
 * @returns {*}
 */
export function updateDepartmentUserBatch (params) {
  return http.post('/security/department/updateDepartmentUserBatch', params, false)
}


/**
 * @description 判断人员的账户名称是否重复
 * @param {String} loginName 名称
 * @param {String} userId 用户id
 * @returns {*}
 */
export function userLoginNameUnique (params) {
  return http.get('/security/user/unique', params)
}

/**
 * @description 判断人员的工号是否重复
 * @param {String} workNo 工号
 * @param {String} userId 用户id
 * @returns {*}
 */
export function userWorkNoUnique (params) {
  return http.get('/security/user/uniqueWorkNo', params)
}

/**
 * @description 获取角色下账号总数和已分配角色的总数
 * @returns {*}
 */
export function getBuyAndUseUserNum (params) {
  return http.get('/setting/getBuyAndUseUserNum', params, false)
}

/**
 * @description 获取角色下人员列表
 * @returns {*}
 */
export function getRoleUser (params) {
  return http.post('/security/user/list', params, false)
}

/**
 * @description 角色添加成员
 * @returns {*}
 */
export function addRoleUser (params) {
  return http.post('/security/role/addUser', params, false)
}

/**
 * @description 角色移除成员
 * @returns {*}
 */
export function delRoleUser (params) {
  return http.post('/security/role/deleteUser', params, false)
}

/**
 * @description 获取角色下已删除人员列表
 * @returns {*}
 */
export function getDelUser (params) {
  return http.post('/security/user/list/getDUserInfo', params, false)
}

/**
 * @description 自动分配角色
 * @returns {*}
 */
export function autoAuth (params) {
  return http.post('/setting/autoAuth/save', params, false)
}

/**
 * @description 重置密码
 * @returns {*}
 */
export function resetPwd (params) {
  return http.post('/security/user/resetPwd', params, false)
}

/**
 * @description 重置密码(2021/09/23用户中心)
 * @returns {*}
 */
 export function resetPwdUpdateAdmin (params) {
  return http.post('/api/user/outside/multi/pwd/update/admin', params, true)
}

/**
 * @description 启用禁用
 * @returns {*}
 */
export function enable (params) {
  return http.post('/security/user/resetPwd', params, false)
}
/**
 * 子部门分页列表
 * 分页
 * @returns {*}
 */
 export function getChildTagList (params) {
  return http.post('/security/tag/getChildTagList', params)
}
/**
 * 新增或编辑成员
 * @returns {*}
 */
 export function createAndAddDepartmentUser (params) {
  return http.post('/security/department/createAndAddDepartmentUser', params,true,{ cancelable: true })
}
/**
 * 人员标签列表
 * @returns {*}
 */
export function getBaseLabelList (params) {
  return http.get('/setting/getBaseLabelList', params)
}

/**
 * 角色列表查询(根据选择的用户展示不同的角色列表),接口用于角色管理中的用户编辑页面
 * @returns {*} String userId
 */
export function getRoleTreeByUser (params) {
  return http.get('/security/role/getRoleTreeByUser', params)
}

/**
 * 根据用户所属部门获取部门树状结构(属于外部服务商部门则只展示外部服务商的部门树),接口用于角色管理中的用户编辑页面
 * @returns {*} String userId
 */
export function getTagTreeByUser (params) {
  return http.get('/security/tag/getTagTreeByUser', params)
}

/**
 * @description 恢复删除账号
 * @returns {*}
 */
export function resume(params) {
    return http.post('/security/user/resume', params, false)
}


/**
 * @description 获取租户所有用户数量及未登录过的用户数
 * @returns {*}
 */
export function getDeptUserCount(params) {
  return http.get('/api/user/outside/user/getLoggedInCount', params)
}

/**
 * @description 获取服务商所有用户数量及未登录过的用户数
 * @returns {*}
 */
export function getServiceUserCount(params) {
  return http.get('/api/user/outside/provider/getLoggedInCount', params)
}

/**
 * @description 给服务商下所有未登录过的工程师发送提醒，tenantProviderId 为空表示针对所有服务商下的工程师
 * @returns {*}
 */
export function sendServiceUserNote(params) {
  return http.get('/api/user/outside/provider/getLoggedInCount', params)
}

/**
 * @description 给租户下所有未登录过的用户发送提醒
 * @returns {*}
 */
export function sendDeptUserNote(params) {
  return http.get('/api/user/outside/user/noLoggedIn/remindAll', params)
}

/**
 * @description 给未登录过的用户发送提醒
 * @returns {*}
 */
export function sendDeptUserItemNote(params) {
  return http.get('/api/user/outside/user/noLoggedIn/remind', params)
}

/**
 * @description 给未登录过的工程师发送提醒
 * @returns {*}
 */
export function sendServiceUserItemNote(params) {
  return http.get('/api/user/outside/provider/noLoggedIn/remind', params)
}




